<style lang="scss" scoped>
	.content {

		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.nav {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
	}

	.top {
		padding: 20rpx 0;
	}

	.search {
		width: 690rpx;
		height: 68rpx;
		background: #f4f5f7;
		border: 2rpx solid #f5f5f5;
		border-radius: 46rpx;
		margin: 0rpx auto;
		padding: 20rpx;

		.ipt {
			flex: 1;
		}
	}

	.footer {
		width: 100%;
		background-color: white;
		position: fixed;
		bottom: 0;
		left: 0;
		border-top: 1px solid #cccccc;
	}

	.box {
		width: 100%;
		padding: 0rpx 20rpx;
		background: #ffffff;

		margin-top: 10rpx;

		.line {
			width: 100%;
			height: 100rpx;
			border-top: 1px solid #eeeeee;

			.ipt {
				width: 500rpx;
				text-align: right;
			}
		}

		.line:first-child {
			border-top: none;
		}



		.line2 {
			width: 100%;
			border-top: 1px solid #eeeeee;
			align-items: flex-start;

			.des {
				width: 500rpx;
				text-align: justify;
			}
		}

		.sbtn {
			width: 184rpx;
			height: 64rpx;
			background: #fffefe;
			border: 2rpx solid #409eff;
			border-radius: 34rpx;
		}

		.imgboxs {
			width: 100%;
			flex-wrap: wrap;

			.imgbox {
				width: 148rpx;
				height: 148rpx;
				border: 2rpx solid #dee2ee;
				border-radius: 10rpx;
				position: relative;
				margin-right: 18rpx;

				.photo {
					width: 100%;
					height: 100%;

				}

				.close {
					position: absolute;
					width: 32rpx;
					height: 32rpx;
					right: -16rpx;
					top: -16rpx;
				}
			}

			.imgbox:nth-child(4n) {

				margin-right: 0rpx;
			}
		}
	}
</style>

<template>
	<view class="content">


		<view class="box">

			<view class="line between-flex f28">
				<view class="gray">创建人</view>
				<view class="blue align-flex"
					@click="peopleType=0;!creatperson?$navTo(PagesCourseRouterConfig.ChoosePerson+'?type=2'):$navTo(PagesCourseRouterConfig.ChoosePerson+'?type=2&users='+leaderperson.value)">
					<span v-if="!creatperson">请选择</span>
					<span v-else class=" align-flex">
						<view style="max-width:370rpx;" class="one">{{creatperson.value | users}}</view>

					</span>
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
			<view class="line between-flex f28">
				<view class="gray">主持人</view>
				<view class="blue align-flex"
					@click="peopleType=1;!leaderperson?$navTo(PagesCourseRouterConfig.ChoosePerson+'?type=2'):$navTo(PagesCourseRouterConfig.ChoosePerson+'?type=2&users='+leaderperson.value)">
					<span v-if="!leaderperson">请选择</span>
					<span v-else class=" align-flex">
						<view style="max-width:370rpx;" class="one">{{leaderperson.value | users}}</view>

					</span>
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
			<view class="line between-flex f28">
				<view class="gray">会议室</view>
				<view class="blue" @click="$navTo(PagesCourseRouterConfig.ChooseMeetingRoom)">
					{{meetingRoom?meetingRoom.name:'请选择'}}
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
			<view class="line between-flex f28">
				<view class="gray">会议类型</view>
				<picker mode="selector" :range="dic.meeting_type" range-key="name" @change="choose">
					<view class=" blue choosearea">
						{{meetType?meetType.name:'请选择'}}
						<u-icon name="arrow-right" color="#409EFF" size="28"></u-icon>
					</view>
				</picker>
			</view>
			<view class="line between-flex f28">
				<view class="gray">所属项目</view>
				<view class="blue" @click="$navTo(PagesCourseRouterConfig.ChooseProject)">
					{{project?project.name:'请选择'}}
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
			<view class="line between-flex f28" @click="showStarttime=true">
				<view class="gray">开始时间</view>
				<view class="blue">{{startTime?startTime:'请选择'}}
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
			<view class="line between-flex f28" @click="showEndtime=true">
				<view class="gray">结束时间</view>
				<view class="blue">{{endTime?endTime:'请选择'}}
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>

		</view>
		<view class="space"></view>
		<view class="footer   paddingBottom">
			<BttonGroup @leftClick="clear()" @rightClick="submit"></BttonGroup>
		</view>
		<u-picker v-model="showStarttime" mode="time" :params="params" @confirm="confirm($event,1)"></u-picker>
		<u-picker v-model="showEndtime" mode="time" :params="params" @confirm="confirm($event,2)"></u-picker>
	</view>
</template>

<script>
	import BttonGroup from '@/components/buttonGroup/groupTwo.vue'
		import PagesCourseRouterConfig from '@/pagesCourse/routerConfig.js'
			import PagesHuiYiRouterConfig from  '@/pagesHuiyi/routerConfig.js'
	export default {
		components: {
			BttonGroup
		},
		data() {
			return {
				PagesCourseRouterConfig,
				dic: uni.getStorageSync('dic'),
				head: this.$head,
				startTime: '',
				endTime: '',
				showStarttime: false,
				showEndtime: false,
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},
				project: null, //所属项目
				meetType: null, //会议类型
				creatperson: null, //创建人
				leaderperson: null, //主持人
				meetingRoom: null, //会议室
			}
		},
		onLoad() {

			uni.$on('choosePerson', (data) => {
				if (this.peopleType == 0) {
					this.creatperson = data
				} else if (this.peopleType == 1) {
					this.leaderperson = data
				}
			})
			uni.$on('clear', () => {
				this.clear()
			})
		},
		beforeDestroy() {
			uni.$off('choosePerson')
			uni.$off('clear')
		},
		methods: {
			choose(e) {
				this.meetType = this.dic.meeting_type[e.detail.value]
			},
			submit() {
				var obj = {

					createUser: this.creatperson ? this.creatperson.value : '',
					hostId: this.leaderperson ? this.leaderperson.value : '',
					meetingRoomId: this.meetingRoom ? this.meetingRoom.id : '',
					meetingType: this.meetType ? this.meetType.value : '',
					itemCode: this.project ? this.project.value : '',

					startTime: this.startTime,
					endTime: this.endTime
				}
				// uni.setStorageSync('options3', obj)
				let queryParams = JSON.stringify(obj)
				wx.redirectTo({
					url: `${PagesHuiYiRouterConfig.Search}?query=${queryParams}`
				})

			},
			clear() {
				this.creatperson = null
				this.leaderperson = null
				this.meetingRoom = null
				this.meetType = null
				this.project = null
				this.startTime = ''
				this.endTime = ''
			},
			confirm(e, index) {
				console.log(e)
				if (index == 1) {
					this.startTime = e.year + '-' + e.month + '-' + e.day
				} else {
					this.endTime = e.year + '-' + e.month + '-' + e.day
				}
			}

		}
	}
</script>
